<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="my.css">
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#loginA").click(function() {
			if($("#id").val()==""){
				alert("ID를 입력하세요!");
				$("#id").focus();
				return false;
			}else if($("#password").val()=="") {
				alert("Password를 입력하세요!");
				$("#password").focus();
				return false;
			}
			$.ajax({
				url : "spc.do?command=login",
				data : $("#loginform").serialize(),
				dataType : "json",
				success : function(js) {
					if (js.msg == "N") {
						alert("ID가 존재하지 않거나 PW가 일치하지 않습니다!");
						$(".tt").val("");
						$(":input:text").focus();
					} else {
						location.href = "index.jsp";
					}
				},
				error : function() {
					alert("error..");
				}
			});
		}); // #loginA click
		$("#mesExit").click(function(){
				alert('Thanks!');
				self.close();
		}); // #mesExit click
	}); //ready
</script>
</head>
<body > 
	<div id="container">
		<div id="index_header"></div>
		<div id="index_main">
			<br>
			<center>
				<img width="400px" src="img/index_title.png">
				<img width="90px" src="img/index_ice.gif">
			</center>
			<div id="login">
				<c:choose>
					<c:when test="${sessionScope.vo!=null}">
						<table width="280px">
							<tr>
								<td rowspan="3" width="25%"><img width="100%" src="img/people.png"></td><td width="25%">Factory</td><td width="50%"><input type="text" size="16" value="DEMO" readonly="readonly"></td>
							</tr>
							<tr>
								<td>User ID</td><td align="left">${sessionScope.vo.mem_id }</td>
							</tr>
							<tr>
								<td>Level</td><td><c:if test="${sessionScope.vo.mem_level =='W'}"><title>팥빙수 공정 MES_사용자</title>Worker</c:if>
								<c:if test="${sessionScope.vo.mem_level =='A'}"><title>팥빙수 공정 MES_관리자</title>Administor</c:if></td>
							</tr>
							</table>
							<table width="280px" height="30px">
							<tr>
							<td width="50%"><c:if test="${sessionScope.vo.mem_level =='W'}"><a href="spc.do?command=fmb" >CONNECTION</a></c:if>
							<c:if test="${sessionScope.vo.mem_level =='A'}"><a href="admin.do?command=fmb" >CONNECTION</a></c:if>
							</td><td><a href="spc.do?command=logout" id="mesExit">LOGOUT</a></td>
							</tr>
						</table>
					</c:when>
					<c:otherwise>
					<title>팥빙수 공정 MES</title>
					<form id="loginform" >
						<table width="280px">
							<tr>
								<td rowspan="3" width="25%"><img width="100%" src="img/people.png"></td><td width="25%">Factory</td><td width="50%"><input type="text" size="16" value="DEMO" readonly="readonly"></td>
							</tr>
							<tr>
								<td>User ID</td><td><input name="mem_id" id="id" class="tt" type="text" size="16" placeholder="ID"></td>
							</tr>
							<tr>
								<td>Password</td><td><input name="password" id="password" class="tt" type="password" size="16" placeholder="PW"></td>
							</tr>
							</table>
							<table width="280px" height="30px">
							<tr>
							<td width="50%"><a href="#" id="loginA">LOGIN</a></td><td><a href="#" id="mesExit">EXIT</a></td>
							</tr>
						</table><br><br>
						<table width="140px">
							<tr>
								<td>
									<a href="member.do?command=main">REGISTER</a>
								</td>
							</tr>
						</table>
						</form>
					</c:otherwise>
				</c:choose>
			</div>
		</div>
	</div>
</body>
</html>